﻿public static class GlobalMembersGame_statusbar
{
	// ****************************************************************************
	// * Punch And Kick -- a simple 2D Fighting Game.
	// *
	// * Copyright (C) 2013 by
	// * Liu Chao
	// *
	// * This file is part of the Punch And Kick project, and may only be used,
	// * modified, and distributed under the terms of the GPLv2.
	// *
	// * (GPLv2 is abbreviation of GNU General Public License Version 2)
	// *
	// * By continuing to use, modify, or distribute this file you indicate that you
	// * have read the license and understand and accept it fully.
	// *
	// * The Punch And Kick project is distributed in the hope that it will be
	// * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 
	// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GPL v2 for
	// * more details.
	// *
	// * You should have received a copy of the GPLv2 along with this file. It is
	// * usually in the LICENSE.TXT file, If not, see <http://www.gnu.org/licenses/>.
	// * **************************************************************************

	// ****************************************************************************
	// * Punch And Kick -- 一个普通的2D格斗游戏
	// *
	// * 版权所有 (C) 2013 归属于
	// * 刘超
	// *
	// * 这个文件是 Punch And Kick 项目的一部分，并且只可以根据GPLv2许可协议来使用、
	// * 更改和发布。
	// *
	// * (GPLv2 是 GNU通用公共许可证第二版 的英文缩写)
	// *
	// * 继续使用、修改或发布本文件，表明您已经阅读并完全理解和接受这个许可协议。
	// *
	// * Punch And Kick 项目是基于技术交流目的而加以散布的，但不负任何担保责任，例
	// * 如：稳定性、可玩性、趣味性等的担保，甚至没有适销性或特定用途的隐含担保，详
	// * 情请参照GPLv2许可协议。
	// *
	// * 您应已收到附随于本文件的GPLv2许可协议的副本，它通常在LICENSE.TXT文件中，如果
	// * 没有，请查看：<http://www.gnu.org/licenses/>.
	// * **************************************************************************

	// 游戏角色状态栏


		public static int hp; //*< 当前生命值 
		public static int max_hp; //*< 最大生命值 
		public static char[] player_name = new char[9]; //*< 玩家名 
		public static char[] type_name = new char[5]; //*< 类型名 
		public static LCUI_Graph_ avatar; //*< 头像 
		public static LCUI_Widget_ img_box; //*< 头像框部件 
		public static LCUI_Widget_ lifebar; //*< 血量条部件 
		public static LCUI_Widget_ lifebar_num; //*< 显示血条数量的部件 
		public static LCUI_Widget_ label_type; //*< 显示类型名的部件 
		public static LCUI_Widget_ label_type_area; //*< 一个容器 
		public static LCUI_Widget_ label_name; //*< 显示玩家名的部件 

    //C++ TO C# CONVERTER NOTE: Access declarations are not available in C#:
    //StatusBarData_;

    //public static LCUI_Widget_ StatusBar_New()
    //{
    //	LCUI_Widget_ widget;
    //	widget = Widget_New(DefineConstantsGame_statusbar.TYPE_NAME);
    //	Widget_Resize(widget, Size(195,80));
    //	return widget;
    //}

    //internal static void StatusBar_ExecInit(LCUI_Widget_ widget)
    //{
    //	StatusBarData_ data;
    //	_LCUI_TextStyle style = new _LCUI_TextStyle();

    //	data = (StatusBarData_)Widget_NewPrivData(widget, typeof(StatusBarData_));
    //	data.avatar = null;
    //	data.hp = 0;
    //	data.max_hp = 2000;
    //	wcsncpy(data.player_name, "匿名", 8);
    //	data.player_name[8] = 0;
    //	wcsncpy(data.type_name, "NONE", 5);
    //	data.player_name[5] = 0;
    //	// 创建部件 
    //	data.img_box = Widget_New(null);
    //	data.label_type = Widget_New("label");
    //	data.label_name = Widget_New("label");
    //	data.lifebar_num = Widget_New(null);
    //	data.label_type_area = Widget_New(null);
    //	data.lifebar = LifeBar_New();
    //	// 加入至本容器 
    //	Widget_Container_Add(widget, data.img_box);
    //	Widget_Container_Add(widget, data.label_type_area);
    //	Widget_Container_Add(widget, data.label_name);
    //	Widget_Container_Add(widget, data.lifebar);
    //	Widget_Container_Add(data.lifebar, data.lifebar_num);
    //	Widget_Container_Add(data.label_type_area, data.label_type);
    //	// 设置默认的文本样式 
    //	TextStyle_Init(style);
    //	TextStyle_FontSize(style, 14);
    //	Label_TextStyle(data.label_type, style);
    //	Label_TextStyle(data.label_name, style);
    //	// 调整尺寸 
    //	Widget_Resize(data.label_type_area, Size(45,15));
    //	Widget_Resize(data.img_box, Size(45,45));
    //	Widget_Resize(data.lifebar, Size(135,25));
    //	// 加上边框 
    //	Widget_SetBorder(data.img_box, Border(1,BORDER_STYLE_SOLID,RGB(150,150,150)));
    //	Widget_SetBorder(widget, Border(1,BORDER_STYLE_SOLID,RGB(150,150,150)));
    //	// 设置布局 
    //	Widget_SetAlign(data.img_box, ALIGN_TYPE_.ALIGN_TOP_LEFT, Pos(5,25));
    //	Widget_SetAlign(data.label_type, ALIGN_TYPE_.ALIGN_MIDDLE_CENTER, Pos(0,0));
    //	Widget_SetAlign(data.label_type_area, ALIGN_TYPE_.ALIGN_TOP_LEFT, Pos(5,5));
    //	Widget_SetAlign(data.label_name, ALIGN_TYPE_.ALIGN_TOP_LEFT, Pos(55+2,5));
    //	Widget_SetAlign(data.lifebar, ALIGN_TYPE_.ALIGN_TOP_LEFT, Pos(55,25));
    //	Widget_SetAlign(data.lifebar_num, ALIGN_TYPE_.ALIGN_MIDDLE_RIGHT, Pos(-2,0));

    //	Widget_SetBackgroundColor(data.img_box, RGB(240,240,240));
    //	Widget_SetBackgroundTransparent(data.img_box, DefineConstantsGame_statusbar.FALSE);
    //	Widget_SetBackgroundColor(widget, RGB(255,255,255));
    //	Widget_SetBackgroundTransparent(widget, DefineConstantsGame_statusbar.FALSE);

    //	// 设置生命条的参数 
    //	LifeBar_SetFullHP(data.lifebar, 400);
    //	LifeBar_SetMaxHP(data.lifebar, data.max_hp);
    //	LifeBar_SetHP(data.lifebar, data.hp);
    //	// 设置显示的文本 
    //	Label_TextW(data.label_type, data.type_name);
    //	Label_TextW(data.label_name, data.player_name);
    //	// 全部显示 
    //	Widget_Show(data.label_type);
    //	Widget_Show(data.label_type_area);
    //	Widget_Show(data.label_name);
    //	Widget_Show(data.img_box);
    //	Widget_Show(data.lifebar);
    //}

    ////* 更新血条数量 
    //internal static void StatusBar_UpdateLifeBarNum(LCUI_Widget_ widget)
    //{
    //	int i;
    //	int n;
    //	int w;
    //	int x;
    //	string str = new string(new char[10]);
    //	string ch = new string(new char[2]);
    //	StatusBarData_ data;
    //	LCUI_Graph_ bg = new LCUI_Graph_();
    //	LCUI_Graph_[] graph = new LCUI_Graph_[5];

    //	data = (StatusBarData_)Widget_GetPrivData(widget);
    //	n = LifeBar_GetBarNum(data.lifebar);
    //	if(n <= 1)
    //	{
    //		Widget_Hide(data.lifebar_num);
    //		return;
    //	}
    //	str = string.Format("{0:D}", n);
    //	n = str.Length;
    //	GameGraphRes_GetGraph(DefineConstantsGame_statusbar.FONT_RES, "x", graph[0]);
    //	if(n > 4)
    //	{
    //		n = 4;
    //	}
    //	w = graph[0].w;
    //	// 预先保存结束符 
    //	ch = ch.Substring(0, 1);
    //	for(i =n-1; i>=0; --i)
    //	{
    //		// 保存当前字符 
    //		ch = StringHelper.ChangeCharacter(ch, 0, str[i]);
    //		// 获取与该字符对应的字体图像 
    //		if(GameGraphRes_GetGraph(DefineConstantsGame_statusbar.FONT_RES, ch, graph[i+1]) != 0)
    //		{
    //			continue;
    //		}
    //		// 累计图像宽度 
    //		w += graph[i+1].w;
    //	}
    //	x = 0;
    //	Graph_Init(bg);
    //	bg.color_type = (int)GraphColorTyle.COLOR_TYPE_RGBA;
    //	// 创建合适尺寸的图像 
    //	Graph_Create(bg, w, 18);
    //	for(i =0; i<=n; ++i)
    //	{
    //		// 将获得到的字体图像覆盖至图像上 
    //		Graph_Replace(bg, graph[i], Pos(x,0));
    //		x += graph[i].w;
    //	}
    //	// 如果有背景图，那就释放它，因为这个部件的背景图只有本函数在设置 
    //	if(Graph_IsValid(data.lifebar_num.background.image))
    //	{
    //		Graph_Free(data.lifebar_num.background.image);
    //	}
    //	// 设置背景 
    //	Widget_SetBackgroundImage(data.lifebar_num, bg);
    //	Widget_SetBackgroundTransparent(data.lifebar_num, DefineConstantsGame_statusbar.TRUE);
    //	Widget_SetBackgroundLayout(data.lifebar_num, LAYOUT_NONE);
    //	// 调整尺寸 
    //	Widget_Resize(data.lifebar_num, Size(w,18));
    //	// 显示在血条前面 
    //	Widget_SetZIndex(data.lifebar_num, 1000);
    //	// 显示之 
    //	Widget_Show(data.lifebar_num);
    //}

    ////* 设置玩家名称(最多8个字) 
    //public static void StatusBar_SetPlayerNameW(LCUI_Widget_ widget, char name)
    //{
    //	StatusBarData_ data;
    //	data = (StatusBarData_)Widget_GetPrivData(widget);
    //	wcsncpy(data.player_name, name, 8);
    //	Label_TextW(data.label_name, data.player_name);
    //}

    //public static void StatusBar_SetPlayerName(LCUI_Widget_ widget, string name)
    //{

    //}

    ////* 设置玩家类型名称，最多4个字，如：1P、2P或CPU 
    //public static void StatusBar_SetPlayerTypeNameW(LCUI_Widget_ widget, char type_name)
    //{
    //	StatusBarData_ data;
    //	data = (StatusBarData_)Widget_GetPrivData(widget);
    //	wcsncpy(data.type_name, type_name, 4);
    //	Label_TextW(data.label_type, data.type_name);
    //}

    //public static void StatusBar_SetPlayerTypeName(LCUI_Widget_ widget, string type_name)
    //{

    //}

    ////* 设置最大生命值 
    //public static void StatusBar_SetMaxHealth(LCUI_Widget_ widget, int @value)
    //{
    //	StatusBarData_ data;
    //	data = (StatusBarData_)Widget_GetPrivData(widget);
    //	if (data == null)
    //	{
    //		return;
    //	}
    //	LifeBar_SetMaxHP(data.lifebar, @value);
    //	StatusBar_UpdateLifeBarNum(widget);
    //}

    ////* 设置当前生命值 
    public static void StatusBar_SetHealth(LCUI_Widget_ widget, int @value)
    {
        //StatusBarData_ data;
        //data = (StatusBarData_)Widget_GetPrivData(widget);
        //if (data == null)
        //{
        //    return;
        //}
        //LifeBar_SetHP(data.lifebar, @value);
        //StatusBar_UpdateLifeBarNum(widget);
    }

    ////* 设置头像 
    //public static void StatusBar_SetAvatar(LCUI_Widget_ widget, LCUI_Graph_ img)
    //{
    //	StatusBarData_ data;
    //	data = (StatusBarData_)Widget_GetPrivData(widget);
    //	if (data == null)
    //	{
    //		return;
    //	}
    //	Widget_SetBackgroundImage(data.img_box, img);
    //	Widget_SetBackgroundLayout(data.img_box, LAYOUT_CENTER);
    //	Widget_SetBackgroundTransparent(data.img_box, DefineConstantsGame_statusbar.FALSE);
    //}

    ////* 注册状态栏部件 
    //public static void StatusBar_Register()
    //{
    //	WidgetType_Add(DefineConstantsGame_statusbar.TYPE_NAME);
    //	WidgetFunc_Add(DefineConstantsGame_statusbar.TYPE_NAME, StatusBar_ExecInit, FuncType_.FUNC_TYPE_INIT);
    //}
}

//----------------------------------------------------------------------------------------
//	Copyright © 2006 - 2009 Tangible Software Solutions Inc.
//	This class can be used by anyone provided that the copyright notice remains intact.
//
//	This class provides miscellaneous helper methods for strings.
//----------------------------------------------------------------------------------------
internal static class StringHelper
{
	//------------------------------------------------------------------------------------
	//	This method allows replacing a single character in a string, to help convert
	//	C++ code where a single character in a character array is replaced.
	//------------------------------------------------------------------------------------
	internal static string ChangeCharacter(string sourcestring, int charindex, char changechar)
	{
		return (charindex > 0 ? sourcestring.Substring(0, charindex) : "")
			+ changechar.ToString() + (charindex < sourcestring.Length - 1 ? sourcestring.Substring(charindex + 1) : "");
	}
}